rm(list=ls())
library("cjoint")
#US Conjoint

setwd("C:/Users/dtingley/Dropbox/M&A - Conjoint Experiment/data/replication/")

load("USConjoint.RData")



results <- amce(cj_response ~  Reciprocity+Country + Owner + Natsec + Firmsize + Distress , data=use, cluster=TRUE, respondent.id="id", design="uniform")

summary(results)

theme_bw_new <- function(base_size = 11, base_family = ""){
  theme_bw(base_size = base_size, base_family = base_family) %+replace%
    theme(axis.text.x = element_text(size = base_size*.9, colour = "black",  hjust = .5 , vjust=1),
          axis.text.y = element_text(size = base_size, colour = "black", hjust = 0 , vjust=.5 ), 
          
          axis.ticks = element_line(colour = "grey50"),
          axis.title.y =  element_text(size = base_size,angle=90,vjust=.01,hjust=.1),
          plot.title = element_text(face = "bold"),
          legend.position = "none")
  
}




# Plot results
pdf("../finalgraphs/USBasicConjointResults.pdf", width=14)
plot(results, xlab="Change in Pr(US should block acquisition)", 
     xlim=c(-.25,.25), breaks=c(-.4,-.2,0,.2,.4), 
     labels=c("-.4","-.2","0",".2", ".4"), text.size=11, plot.theme=theme_bw_new(), colors="black"
)
dev.off()



#China Conjoint

load("C:/Users/dtingley/Dropbox/M&A - Conjoint Experiment/data/replication/ChinaConjoint.RData")

# Run AMCE estimator - this calls the main amce() function in the cjoint package
results <- amce(cj_response.n ~  Ownership + Firmsize + Distress +Reciprocity, data=use, cluster=TRUE, respondent.id="id", design="uniform")

summary(results)


theme_bw_new <- function(base_size = 11, base_family = ""){
  theme_bw(base_size = base_size, base_family = base_family) %+replace%
    theme(axis.text.x = element_text(size = base_size*.9, colour = "black",  hjust = .5 , vjust=1),
          axis.text.y = element_text(size = base_size, colour = "black", hjust = 0 , vjust=.5 ), 
          
          axis.ticks = element_line(colour = "grey50"),
          axis.title.y =  element_text(size = base_size,angle=90,vjust=.01,hjust=.1),
          plot.title = element_text(face = "bold"),
          legend.position = "none")
  
}


# Plot results
pdf("../finalgraphs/ChinaMnAConjoint.pdf", width=10)
plot(results, xlab="Change in Pr(China should block acquisition)", 
     xlim=c(-.25,.25), breaks=c(-.4,-.2,0,.2,.4), 
     labels=c("-.4","-.2","0",".2", ".4"), text.size=11, plot.theme=theme_bw_new(), colors="black"
)
dev.off()